{% extends "nav.html" %}
{% block little %}主机信息{% endblock %}
{% block content %}

    <style>
        .select2-container {
            width: 100% !important;
            padding: 0;
            z-index:9999999;
        }
    </style>
    <!-- Main Content -->
    <div class="container-fluid">
        <div class="side-body">
            <div class="page-title">
                <span class="title">主机信息查看</span>
                <div class="description">网服所有主机信息查看</div>
            </div>
            <div class="row">
                <div class="col-xs-12">
                    <div class="card">
                        <div class="card-header">

                            <div class="card-title">
                                <div class="title">信息采集</div>
                            </div>
                        </div>
                        <div class="card-body">
                            <table class="datatable table table-striped table-hover" cellspacing="0" width="100%">
                                <thead>
                                <tr>
                                    <th style="margin-left: -10px"><input type="checkbox" /></th>
                                    <th>厂商</th>
                                    <th>型号</th>
                                    <th>IP</th>
                                    <th>端口槽位</th>
                                    <th>详情</th>
                                    <th>状态</th>
                                    <th>操作</th>
                                </tr>
                                </thead>
                                <tfoot>
                                <tr>
                                    <th><input type="checkbox" /></th>
                                    <th>厂商</th>
                                    <th>型号</th>
                                    <th>IP</th>
                                    <th>端口槽位</th>
                                    <th>详情</th>
                                    <th>状态</th>
                                    <th>操作</th>
                                </tr>
                                </tfoot>
                                <tbody>
                                <tr>
                                    <th><input type="checkbox" /></th>
                                    <th>博科</th>
                                    <th>DCX4s</th>
                                    <th>10.226.24.224</th>
                                    <th>1-15</th>
                                    <th>收集相关信息</th>
                                    <th>运行中</th>
                                    <th>
                                        <a type="button" nid="" class="btn btn-warning btn-xs st_sel_update" style="margin: 0px 0px;top: 0px;" >开始</a>
                                        <a type="button" nid="" class="btn btn-success btn-xs st_sel_update" style="margin: 0px 0px;top: 0px;" >结束</a>
                                        <a type="button" nid="" class="btn btn-info btn-xs st_sel_update" style="margin: 0px 0px;top: 0px;" >视图查看</a>
                                    </th>
                                </tr>
                                </tbody>
                            </table>
                            <div>
                                <a type="button" class="btn btn-success" id="caiji_duankou_update">光交端口添加</a>
                                <a type="button" class="btn btn-success" id="caiji_host_update">主机添加</a>
                                <a type="button" class="btn btn-primary" id="storage_update">删除</a>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div>
        <div class="modal fade caiji_port_edit"  role="dialog" aria-labelledby="gridSystemModalLabel" id="caiji_port_edit" >
            <div class="modal-dialog" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title" id="gridSystemModalLabel">添加</h4>
                    </div>

                    <div class="modal-body ">

                        <div class="row">
                            <div>
                                <div class="col-md-6"><h5>光交IP：</h5></div>
                                <div class="col-md-3"><h5>光交槽位：</h5></div>
                                <div class="col-md-3"><h5>光交端口：</h5></div>
                            </div>
                            <div>
                                <div class="col-md-6">
                                    <select id = "caiji_san" class="select2-dropdown caiji_san">
                                        {% for i in data %}
                                            <option name="{{ i.id }}">{{ i }}---{{ i.sn }}</option>
                                        {% endfor %}
                                    </select>
                                </div>
                                <div class="col-md-3">
                                    <select class="select2-dropdown" id="caiji_slot caiji_san">
                                        <option></option>
                                    </select>
                                </div>
                                <div class="col-md-3">
                                    <select class="select2-dropdown caiji_port caiji_san" id="caiji_port">
                                        <option></option>
                                    </select>
                                </div>
                            </div>
                            <div>
                            </div>
                        </div>
                        {##}
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">关  闭</button>
                        <button type="button" class="btn btn-primary">保  存</button>
                    </div>
                </div><!-- /.modal-content -->
            </div><!-- /.modal-dialog -->
        </div><!-- /.modal -->
    </div>
    <div>
        <div class="modal fade caiji_host_edit"  role="dialog" aria-labelledby="gridSystemModalLabel" id="caiji_host_edit" >
            <div class="modal-dialog" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title" id="gridSystemModalLabel">服务器采集添加</h4>
                    </div>

                    <div class="modal-body ">

                        <div class="row">
                            <div>
                                <div class="col-md-3"><h5>IP：</h5></div>
                                <div class="col-md-2"><h5>端口：</h5></div>
                                <div class="col-md-2"><h5>账号：</h5></div>
                                <div class="col-md-2"><h5>密码：</h5></div>
                                <div class="col-md-3"><h5>提权密码：</h5></div>
                            </div>
                            <div>
                                <div class="col-md-3">
                                    <input type="text" class="form-control" id="caiji_ip" placeholder="ip">
                                </div>
                                <div class="col-md-2">
                                    <input type="text" class="form-control" id="caiji_port" placeholder="port">
                                </div>
                                <div class="col-md-2">
                                    <input type="text" class="form-control" id="caiji_root" placeholder="root">
                                </div>
                                <div class="col-md-2">
                                    <input type="password" class="form-control" id="caiji_password" placeholder="password">
                                </div>
                                <div class="col-md-3">
                                    <input type="password" class="form-control" id="caiji_su_pass" placeholder="su_password">
                                </div>
                            </div>
                            <div>
                                <div class="col-md-12"><h5>详细说明</h5></div>
                            </div>
                            <div class="row">
                                <div class="col-md-12">
                                    <input type="text" class="form-control" id="caiji_note" placeholder="详情">
                                </div>

                            </div>
                            <div>
                            </div>
                        </div>

                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">关  闭</button>
                        <button type="button" class="btn btn-primary caiji_host_save">保  存</button>
                    </div>
                </div><!-- /.modal-content -->
            </div><!-- /.modal-dialog -->
        </div><!-- /.modal -->
    </div>
{% endblock %}
{% block js %}
    <script>
        $("#caiji_duankou_update").click(function () {
            $("#caiji_port_edit").modal({backdrop: 'static', keyboard: false},'toggle')
            $("#caiji_san").change(function () {
                var sanid = $("#caiji_san").find("option:selected").attr("name");
                $.ajax({
                    url: "{% url "caiji_san_port" %}",
                    type: 'POST',
                    data:{id:sanid},
                    success: function(data){
                        var obj = JSON.parse(data);
                        if(obj.status){
                            var a = obj.slot
                            var b = obj.port
                            $("#caiji_slot").empty()
                            $("#caiji_port").empty()
                            for(var i = 0;i < a.length; i++){
                                $("#caiji_slot").append(a[i])
                            };
                            for (var i = 0;i < b.length; i++){
                                $("#caiji_port").append(b[i])
                            }
                        }else{
                        };
                    }
                });
            })
        });
        $("#caiji_host_update").click(function () {
            $("#caiji_host_edit").modal({backdrop: 'static', keyboard: false},'toggle')
            $("#caiji_san").change(function () {
                var sanid = $("#caiji_san").find("option:selected").attr("name");
                $.ajax({
                    url: "{% url "caiji_san_port" %}",
                    type: 'POST',
                    data:{id:sanid},
                    success: function(data){
                        var obj = JSON.parse(data);
                        if(obj.status){
                            var a = obj.slot
                            var b = obj.port
                            $("#caiji_slot").empty()
                            $("#caiji_port").empty()
                            for(var i = 0;i < a.length; i++){
                                $("#caiji_slot").append(a[i])
                            };
                            for (var i = 0;i < b.length; i++){
                                $("#caiji_port").append(b[i])
                            }
                        }else{
                        };
                    }
                });
            })
        });

    </script>
{% endblock %}